/*====================================================*/
/* Copyright 2011 Justin Middleton                    */
/* License: Eclipse Public License v1.0,              */
/*          http://www.eclipse.org/legal/epl-v10.html */
/*====================================================*/

Array.prototype.equals = function(that){
    if (!(that instanceof Array)) {
        return false
    }
    if (this.length != that.length ) {
        return false
    }
    for (var i = 0; i < this.length; i++) {
        if (!(this[i] === that[i])) {
            return false
        }
    }
    return true
}

this.testArrayEquals = function() {
    failures = []
    
    array = [1,2,3,4]
    if (!array.equals([1,2,3,4])) {
        failures.push("testArrayEquals.Test1 -- should equal       -- FAIL")
    }
    
    if (array.equals("foo")) {
        failures.push("testArrayEquals.Test2 -- compare to string  -- FAIL")
    }
    
    if (array.equals("[1,2]")) {
        failures.push("testArrayEquals.Test2 -- compare uneq leng  -- FAIL")
    }
    
    if (array.equals(['1', '2', '3', '4'])) {
        failures.push("testArrayEquals.Test3 -- compare to str arr -- FAIL")
    }
    
    return failures
}

this.runTests = function() {
    failures = []
    failures.concat(this.testArrayEquals())
    return failures
}